import WorkerMSDB
import sys
reader = WorkerMSDB.Worker('localhost', '2929', 'PGSMData', 'sa', 'safeinside')
reader.connect()
c = reader.connection.cursor()
query = 'SELECT TOP (250) id,deviceId,eventId,eventTime,rs232str,SaveTime FROM _rs232_data WHERE deviceId=605'
c.execute(query)
d = c.fetchall()

#for s in d: print s

for e in d:
	print e[4].decode('cp866')
#	for i in e[4]: sys.stdout.write('%s:%d ' % (i.decode('cp866'), ord(i)))
	sys.stdout.write('\n')

	
